import { useSelector } from "react-redux";
import type { StateType } from "../store";
import type { ComponentsStateType } from "../store/componentsReducer";

export default function useGetComponentInfo() {
  const components = useSelector<StateType>(
    (state) => state.components
  ) as ComponentsStateType;
  const { componentList = [], selectedId } = components;
  const selectedComponent = componentList.find((c) => c.fe_id == selectedId);
  return {
    componentList,
    selectedId,
    selectedComponent,
  };
}
